package tool.softT

import implicits.Implicits._
import shared.Pojo._
import tool.Pojo._
import shared.Pojo._
import tool.plot.{RfPlot, SvmPlot}
import tool._

import java.io.File
import dao._
import play.api.i18n.Messages

/**
 * Created by yz on 7/12/2020
 */
trait SvmSoftBT extends AllSoftBT with SvmSoftT {

  override def getFileInfos(workspaceDir: File, index: Int)(implicit matrixFileDataDao: MatrixFileDataDao, messages: Messages): List[FileInfoData] = {
    List(
      FileInfoData("SVM_Imp.pdf", messages("sVMImp")),
      FileInfoData("SVM_Imp_Rank.csv", messages("sVMImpRank")),
      FileInfoData("Diff_Metabolite.csv", messages("diffMetabolite")),
    )
  }

  override def getCommandData(workspaceDir: File, resultDir: File, index: Int): List[CommandData] = {
    val solutionFile = new File(Tool.dataDir, "color_solution/color_solution_1.txt")
    val rawDataFile = new File(workspaceDir, "AllMet_Raw.txt")
    val standardFile = Tool.getStandardFile(workspaceDir)
    val inputMetabolites=Tool.inputMetabolites(workspaceDir)
    val command =if(inputMetabolites.nonEmpty) {
      s"""
         |${"Rscript".condaPath()} ${Tool.rPath.unixPath}/standard.R
         |${"Rscript".condaPath()} ${new File(Tool.rPath, "svm_calculate.R").unixPath} --i ${standardFile.unixPath}
         |${"Rscript".condaPath()} ${new File(Tool.rPath, "svm_filter.R").unixPath}
         |${"Rscript".condaPath()} ${new File(Tool.rPath, "svm_plot.R").unixPath} --pc ${SvmPlot.configFileName}
           """.stripMargin
    }else ""
    List(CommandData(workspaceDir, List(command)))
  }

  override def producePlotConfigFile(workspaceDir: File, index: Int): Any = {
    Tool.producePlotConfigFile(AllPlotData(), SvmPlot, workspaceDir)
  }


}
